0
Welcome Guest! Login
0 items Join Now

ROCKETTHEME IS CLOSING ON JUNE 30, 2025. As a thank-you to our community, enjoy 50% off all themes with the promo code THANKYOU before we shut down. Read our Farewell Blog Post for more details.

Remove a javascript from a page?

    • UgoT's Avatar
    • UgoT
    • Newbie
    • Posts: 9
    • Thanks: 0

    Remove a javascript from a page?

    Posted 12 years 9 months ago
    • Hi guys,

      Is there a trick for removing a javascript that conflicts in some pages?
    • prim's Avatar
    • prim
    • Preeminent Rocketeer
    • Posts: 17290
    • Thanks: 217

    Re: Remove a javascript from a page?

    Posted 12 years 9 months ago
    • Unpublish the module on those specific pages?
    • Please reply with a direct link to the issue & create a new thread for each new issue.

      A template is only as good as the content that goes into it ;) - DanG
    • UgoT's Avatar
    • UgoT
    • Newbie
    • Posts: 9
    • Thanks: 0

    Re: Remove a javascript from a page?

    Posted 12 years 9 months ago
    • Thanks Prim,

      The problem is more difficult than it appears. The javascript is loading on every page (It's loaded by a plugin) and i need to unset it only on some pages. How can i do it?
    • prim's Avatar
    • prim
    • Preeminent Rocketeer
    • Posts: 17290
    • Thanks: 217

    Re: Remove a javascript from a page?

    Posted 12 years 9 months ago
    • Does it load the JS even if the module is unpublished??
    • Please reply with a direct link to the issue & create a new thread for each new issue.

      A template is only as good as the content that goes into it ;) - DanG
    • UgoT's Avatar
    • UgoT
    • Newbie
    • Posts: 9
    • Thanks: 0

    Re: Remove a javascript from a page?

    Posted 12 years 9 months ago
    • prim wrote:
      Does it load the JS even if the module is unpublished??
      As I wrote before, the JS is loaded by a plugin. If i depublish the plugin, obviously the JS isn't loaded. But I need that plugin and I'm sure there's a code solution for load it only on some pages.

      I hope you can understand better my problem now. :)
    • UgoT's Avatar
    • UgoT
    • Newbie
    • Posts: 9
    • Thanks: 0

    Re: Remove a javascript from a page?

    Posted 12 years 9 months ago
    • UgoT wrote:
      prim wrote:
      Does it load the JS even if the module is unpublished??
      As I wrote before, the JS is loaded by a plugin. If i depublish the plugin, obviously the JS isn't loaded. But I need that plugin and I'm sure there's a code solution for load it only on some pages.

      I hope you can understand better my problem now. :)

      Ok, i just found a solution, but i'm testing it!

      $document = JFactory::getDocument(); 
                     $headData = $document->getHeadData();
                     $scripts = $headData['scripts'];
                     unset($document->_scripts['http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js']);
                     unset($document->_scripts['/plugins/system/lazyloadforjoomla/lazyloadforjoomla.js']);

      This code must be conditioned by $option var (that defines what component is working on that page) or $ItemId, that defines the ID of the menu voice.

Time to create page: 0.069 seconds