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
2m ago Learn the essential skills to navigate the Shopify admin with confidence. T...
By Shopify Feb 12, 2025Learn how to expand your operations internationally with Shopify Academy’s learning path...
By Shopify Feb 4, 2025Hey Community, happy February! Looking back to January, we kicked off the year with 8....
By JasonH Feb 3, 2025