All things Shopify and commerce
Hello
I am creating the shopify public app and did some jquery code in the app in front end. I need to include jquery library in the front end via app with the help of theme extensions. Please let me know how i can do this. below is code example i need to include via schema.
{% schema %} { "name": "Lyfsize", "target": "section", "stylesheet": "front_shop.css", "javascript": "front_shop.js", "templates": ["product", "index"], "settings": [ { "type": "text", "id": "heading", "label": "Heading", "default": "Click here" }, { "type": "color", "id": "text_color", "label": "Text Color for anchor tag", "default": "#000000" }, { "type": "color", "id": "form_text_color", "label": "Text Color for Form Label", "default": "#000000" }, { "type": "color", "id": "form_button_text_color", "label": "Text Color for Submit Button", "default": "#ffffff" }, { "type": "color", "id": "form_button_background_color", "label": "Submit Button background color", "default": "#000000" }, { "type": "checkbox", "id": "show_announcement", "label": "Show Form", "default": false } ] } {% endschema %}
At the top of the javascript file you are loading (in your case the front_shop.js), add the following:
function include(filename, onload) {
var head = document.getElementsByTagName('head')[0];
var script = document.createElement('script');
script.src=filename;
script.type = 'text/javascript';
script.onload = script.onreadystatechange = function() {
if (script.readyState) {
if (script.readyState === 'complete' || script.readyState === 'loaded') {
script.onreadystatechange = null;
onload();
}
}
else {
onload();
}
};
head.appendChild(script);
}
include('http://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js');
This will load the jquery library and allow you to use jquery functions in your front_shop.js
Learn how to build powerful custom workflows in Shopify Flow with expert guidance from ...
By Jacqui May 7, 2025Did You Know? May is named after Maia, the Roman goddess of growth and flourishing! ...
By JasonH May 2, 2025Discover opportunities to improve SEO with new guidance available from Shopify’s growth...
By Jacqui May 1, 2025