Skip to main content

Bug Tracker

Side navigation

#12909 closed feature (duplicate)

Opened November 16, 2012 11:04AM UTC

Closed November 21, 2012 06:02PM UTC

Dynamically loading CSS.

Reported by: sam@mousa.nl Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.8.3
Keywords: Cc:
Blocked by: Blocking:
Description

Currently jQuery offers a very easy way to dynamically load extra javascript via .getScript().

When dynamically loading CSS however, no such function is available.

This is generally not a problem since the code sample below does what we need and is still pretty clear.

$('head').prepend('<link rel="stylesheet" type="text/css" href="dynamic.js" />');

One of jQuery's strengths is that it normalizes browser specific quirks; for dynamic loading of CSS in IE8 (and maybe others: http://msdn.microsoft.com/en-us/library/ms531194%28VS.85%29.aspx).

Instead a builtin function is avaible in ie8 which must be used, furthermore the loading via $('head').prepend can even cause ie8 to crash, making a website unusable for some user.

I propose adding a new function to jQuery: .getCss(). At the start only 2 arguments would be needed: the url and the index.

Attachments (0)
Change History (1)

Changed November 21, 2012 06:02PM UTC by dmethvin comment:1

resolution: → duplicate
status: newclosed

Duplicate of #9832.I don't think we'd add another method for this, but it would be easily implemented if we do #9832 so I'll mark this ticket as a dup of that.