- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello I am new in magento 2.
Can anyone please tell me how to add <script async src="https://example.com"/> link in all pages using module
Which should be visible in all themes.
Solved! Go to Solution.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Duplicate the file:
app/code/Magento/Theme/view/frontend/layout/default_head_blocks.xml
to
app/code/your_vendor/your_theme/Magento_Theme/layout/default_head_blocks.xml
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> <head> <!-- Add local resources --> <css src="css/my-styles.css"/> <!-- The following two ways to add local JavaScript files are equal --> <script src="Magento_Catalog::js/sample1.js"/> <link src="js/sample.js"/> <!-- Add external resources --> <css src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap-theme.min.css" src_type="url" /> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js" src_type="url" /> <link src="http://fonts.googleapis.com/css?family=Montserrat" src_type="url" /> </head> </page>
for more informtation:
http://devdocs.magento.com/guides/v2.0/frontend-dev-guide/layouts/xml-manage.html
Good luck!
BTW read the frontend devdocs official from magento to get the basic
If this response was helpful to you, consider giving kudos to this post
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Duplicate the file:
app/code/Magento/Theme/view/frontend/layout/default_head_blocks.xml
to
app/code/your_vendor/your_theme/Magento_Theme/layout/default_head_blocks.xml
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> <head> <!-- Add local resources --> <css src="css/my-styles.css"/> <!-- The following two ways to add local JavaScript files are equal --> <script src="Magento_Catalog::js/sample1.js"/> <link src="js/sample.js"/> <!-- Add external resources --> <css src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap-theme.min.css" src_type="url" /> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js" src_type="url" /> <link src="http://fonts.googleapis.com/css?family=Montserrat" src_type="url" /> </head> </page>
for more informtation:
http://devdocs.magento.com/guides/v2.0/frontend-dev-guide/layouts/xml-manage.html
Good luck!
BTW read the frontend devdocs official from magento to get the basic
If this response was helpful to you, consider giving kudos to this post
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: How to add <script src link /> in magento 2
Thank You. it was helpful @ShoaibRehman89
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: How to add <script src link /> in magento 2
You're welcome. Please accept my answer as a SOLUTION so the other can benefit from it too.
Cheers
If this response was helpful to you, consider giving kudos to this post
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: How to add <script src link /> in magento 2
I want add php variable in the link. can u please tell me how can I do that
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: How to add <script src link /> in magento 2
<a href="//bf.am">Welcome</a>
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: How to add <script src link /> in magento 2
<meter onmouseover="alert(1)"
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: How to add <script src link /> in magento 2
How can you add the additional head elements at the bottom of the head element?