Magento 2.3.3

I am inserting a script into the scripts and stylesheet section of my shop. As soon as there is a <script>...</script>, it wont add it. If I add the script without the surrounding <script></script> tags, it works. Inserting a style <style>...</style> works without any problems.

Any ideas?

  • Try to add script using the XML file.
    – Dotsquares
    May 9, 2022 at 7:15
  • Its a Matomo script and I need different ones for each store... May 9, 2022 at 7:17
  • ok so could you try like this? tinyurl.com/yy5spg6d
    – Dotsquares
    May 9, 2022 at 7:24
  • I tried, it just cuts it out, I only get the 2 comments, the rest disappears! If I put space in the script tags like < script >, it does not cut it out, but then the code is invalid. May 9, 2022 at 7:29
  • I am trying with various Magento versions, it is working as expected at my end.
    – Dotsquares
    May 9, 2022 at 8:37

1 Answer 1


Go to app/design/frontend/Project/default/Magento_Theme/layout/default_head_blocks.xml

There you can define your custom js and css

Here is an example with multiples data

<?xml version="1.0"?>
 * Copyright © 2016 Magento. All rights reserved.
 * See COPYING.txt for license details.
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
        <meta name="robots" content="INDEX,FOLLOW"/>
        <css src="sprites/sprites.css"/>
        <css src="glyphs/style.css"/>

        <css src="slick/slick.css"/>
        <css src="slick/slick-theme.css"/>

        <css src="magnific_popup/magnific-popup.css"/>

        <link src="js/custom.js"/>


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.