Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Link in JS/CSS more resiliently #65

Open
joshribakoff opened this issue Oct 1, 2013 · 1 comment
Open

Link in JS/CSS more resiliently #65

joshribakoff opened this issue Oct 1, 2013 · 1 comment

Comments

@joshribakoff
Copy link
Member

Either use layout.xml, or prefix the path with logic to get the base path if running Magento in a sub-directory.

I kind of prefer the latter, because other Magento extensions install jQuery... when users get two jqueries on the page it resets previously loaded plugins. Should research to see how other extensions solve this (probably they don't) - but one idea would be loop through all the layout XML nodes & pattern match it for the string "jquery" and only add it if its not found, that could be a huge performance hit. So another option would just be a setting for the user to toggle if things don't look right - problem there is our extension loads prior to the conflicting extension, it would be the conflicting extension that needs it's jquery disabled - responsibility would be on the conflicting extension to not include duplicate jquery, but if the user installed that extension before ours they will invariably blame us, so a solution would be nice here.

@joshribakoff
Copy link
Member Author

Here's the solution - not sure if it works with Magento's XML. Basically you do the checking if its already loaded in JS (not PHP checking the XML). This makes sure that it doesn't load it in our module even if someone hard coded it into a template, or didn't call it "jquery.js", etc.

http://stackoverflow.com/questions/7102786/is-it-bad-to-add-jquery-multiple-times-on-a-page

As for the base path, there's a Magento, ZF, or $_SERVER way of checking what the request URI was, and using dirname() to get the base path (that's if ZF's function doesn't work with Magento, or Magento doesn't provide the base path which I think it should)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant