function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Prasad RuwanpathiranaPrasad Ruwanpathirana 

How to add script files to a salesforce lightning application?

When I'm adding script files to a lightning component i'm getting an error as 'script tags only allowed in templates: Source'. Is there another way to add script links to the lightning application?
Best Answer chosen by Prasad Ruwanpathirana
Grazitti TeamGrazitti Team
Hi Prasad,

Following link will surely help you.
http://blog.enree.co/2014/11/salesforce-lightning-loading-scripts.html

--
Regards,
Grazitti Team
Web: www.grazitti.com
Email: sfdc@grazitti.com

All Answers

Grazitti TeamGrazitti Team
Hi Prasad,

Following link will surely help you.
http://blog.enree.co/2014/11/salesforce-lightning-loading-scripts.html

--
Regards,
Grazitti Team
Web: www.grazitti.com
Email: sfdc@grazitti.com
This was selected as the best answer
Prasad RuwanpathiranaPrasad Ruwanpathirana
Here we need to create link or script tags dynamically in the component's controller doInit function.
 
({
doInit : function(component, event, helper) {

    if (typeof require !== "undefined") {
           //
           //
        } else {
            //Create head tag dynamically
            var head = document.getElementsByTagName('head')[0];

            //Create link or script tag dynamically
            var link = document.createElement('link');

            //Add appropriate attributes
            link.href = "/resource/bootstrap"; 
            link.rel = "stylesheet";

            head.appendChild(link);
        } 

},//Delimiter for future code