How to add an external javascript/css file to Magento?

Few years ago, we had an article describing how to add external files into Magento.
It was quite popular, so we decided to come back to it today.
Knowing that there is no way to add or remove external files via Magento layout using action/methods, this extension was introduced.

Starting from there, it was possible to use two new methods in your layout.

<!-- Along with these 3 methods --><actionmethod="addJs"><actionmethod="addCss"><actionmethod="addItem"><!-- you can use additional two methods --><actionmethod="addExternalItem"><actionmethod="removeExternalItem">

addExternalItem and removeExternalItem were just aliases of addItem and removeItem added to Inchoo_Xternal_Block_Html_Head which is the class this extension is rewriting.

Of course, nobody would rewrite class just to add methods aliases so the main thing was adding two new types there: external_css and external_js.

“Depends” is a keyword here and one of the main reason why we got back to this article again.

Even though this extensions works now (5 years later) and even though it found it’s home in some of our projects, very important point that wasn’t made when the article was originally published.
This is the third party code. If it’s clean and nice and if you are adding many external files into your installation it can really help you speed things up, but average site doesn’t need that many external files.

So why would you want to have 3rd party extension just to be able to support your theme?

There are many developers around the globe that are looking for quick solution no matter is that the best tool for the job. Result is a website which is made of 100+ installed extensions and majority of those extensions are rarely used. Most of them are installed, I would guess, because developer was looking for an easy and dirty solution.

After some time, that becomes a burden. New developers need more time to get familiar with the project, site gets slow, maintenance becomes horror – there is just more point of failures than you actually need on an average site.

When you publish a Magento related code on the blog, that’s mostly the result of playing with Magento, but many people will use it in real life situations which isn’t always the best idea.

I am not saying that this extension is wrong, I would just like to point out that using it on an average site is not needed. Many people ended up installing the extension just to add 3 lines of text to their shop.

Unless you are already developing similar set of tools that you plan to use as a starting point on most of your sites, there are more simple solutions.

So, even though you are still free to use the extension as much as you like, we recommend that you do that in case you know why exactly you need it, otherwise, do the following:

1 comment

List out admin user id who add the product in magento.
i have created user1 and user2 only to add the product and I want to show there ID in a new column I want to add new column in catlog/Manage Product before name column.

Your email address will not be published. Required fields are marked *

Comment

You may use these HTML tags and attributes: <a href="" title=""> <blockquote cite=""> <code> <del datetime=""> <em> <s> <strike> <strong>. You may use following syntax for source code: <pre><code>$current = "Inchoo";</code></pre>.