Hi I'm trying to include an external css/js in Magento. From what I found one suggestion is to put this under


which is what I did and was able to achieve this. But the issue with this approach is that it's application wide meaning all website, store and other view will have this CSS and JS.

But what I would want is that it should only be applied on a per website level. So let say I have :

**website id = 1** which include **123.css** and **123.js**

**website id = 2** will include **234.css** and **234.js**

But I have no idea on how to achieve this. I'm willing to change my current approach as long as this is achieve. Right now the application is reading from default.xml which all website will include also.

Is there a way to make it so that website 1 will include default1.xml and website 2 will include default2.xml or something? and Magento will include this xml file depending on the website requesting this.

Any suggestion would be much appreaciated. Below is the content of my default.xml

<?xml version="1.0"?>
<page xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <!-- Add js using link tag-->
        <link src="js/external_js_include.js"/>        
        <css src="css/external_css_include.css" />


2 Answers 2


You can create multiple custom themes, each for a single website and on each custom theme, you can use separate default.xml.

  • that could work.. I could try that one then. Will accept your answer if this solves it Commented Feb 20, 2019 at 8:36

You can try something like this : enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.