I am trying to load a classic console related library only when the a Lightning Component is running in a VisualForce container. Unfortunately, adding the ltng:require component dynamically does not make the library available nor is the afterScriptLoaded method executed. Should this work?

Here is the helper function I am calling:

loadClassicLibrary : function(component) {
            "scripts": '/support/console/46.0/integration.js',
            "afterScriptsLoaded": component.getReference("c.classicConsoleInit")
        function(scriptComp, status, errorMessage){
            //Add the new button to the body array
            if (status === "SUCCESS") {
                var body = component.get("v.body");
                component.set("v.body", body);
                console.log("'navigation: Helper: loadClassicLibrary: component added.", JSON.stringify(scriptComp));

            else if (status === "INCOMPLETE") {
                console.log("'navigation: Helper: loadClassicLibrary: No response from server or client is offline.")
                // Show offline error
            else if (status === "ERROR") {
                console.log("navigation: Helper: loadClassicLibrary: Error: " + errorMessage);
                // Show error message

Per the browser console, the script file is accessed at the expected time. What am I missing?

1 Answer 1


Adding the condition in the component markup is a viable work-around. I'd still love to hear if the original question has a solution.


<aura:if isTrue="{!or(v.type=='CL',v.type=='VFLX')}">
<ltng:require scripts="{!('/support/console/47.0/integration.js')}" afterScriptsLoaded="{!c.classicConsoleInit}"/></aura:if>

The init method sets the v.type attribute, which then dynamically renders the ltng:require element.

The library becomes available and the afterScriptsLoaded method executed as expected.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .