IE's 31 stylesheets bug vs. CKEditor custom skin
IE bug forces a rethink
Up until now we've been quite happily using a custom CKEditor skin in its raw, unminified state. Then we received a call from a client, saying that she was getting weird errors when using the Smallbox admin interface in Internet Explorer. Turns out that she was being hit by a somewhat mind-boggling bug: IE--all versions--will only apply the first 31 stylesheets specified. When un-minified, the number of stylesheet files needed by the Smallbox CKEditor skin, combined with the number of Smallbox stylesheets, can exceed this limit.
One of the steps toward alleviating the problem is to minify (compress and obfuscate) our custom skin. However, CKEditor doesn't make it very clear how to do this, and there isn't much information out there on the topic. Which is odd, because this isn't the only reason you might want to minify a custom skin or plugin.
CKPackager: Not the right tool
When researching the issue, CKPackager can look like a promising tool. It's available from the CKEditor SVN tree in both .exe and .jar formats. While it does take care of minifying the core code of CKEditor, this only does the core and will not minify skins, dialogs, themes, and so on, and so won't help us.
For more information on this tool (which we will not use here) visit http://alfonsoml.blogspot.com/2009/12/recompressing-ckeditorjs-to-fit-your.html
CKReleaser: The tool we need
CKEditor also provides CKReleaser, which does do what we need. However, it is intended for use with the SVN version of CKEditor, so a few more steps to custom skin minification in CKEditor are required.
CKReleaser is included within the CKEditor SVN tree, so you don't have to install anything beyond what is detailed below.
Note: in the example below, I'm using a working directory named _ckeditor/, which I have created next to the existing ckeditor/ directory which contains our custom, unminified Smallbox skin. I'm assuming that the current working directory is the directory which contains the existing ckeditor/ directory unless otherwise stated.
-
Check out the CKEditor SVN trunk:
% svn checkout \
http://svn.fckeditor.net/CKEditor/trunk/ _ckeditorThis will fetch the CKEditor SVN trunk and place it into the _ckeditor directory.
-
Copy the needed custom skin files into the source tree:
% cp -a ckeditor/_source/skins/smallbox/ \
_ckeditor/_source/skins/
% cp -a ckeditor/smallbox.js _ckeditor/ -
Edit _ckeditor/ckeditor.pack to tell the releaser to include the custom 'smallbox' skin when building a release package. In our case, I found the line which bundles the included 'kama' skin:
'_source/skins/kama/skin.js',. . .and inserted the following line after it:
'_source/skins/smallbox/skin.js', -
For cleanliness, I also modified the _ckeditor/_dev/releaser/release.sh script slightly to mark the generated release as containing Smallbox-specific changes or code. I changed the following line:
java -jar ckreleaser/ckreleaser.jar \
ckreleaser.release \
../.. release "3.4.1 (SVN)" \
ckeditor_3.4.1_svn --run-before-release=$LANGTOOL. . .to:
java -jar ckreleaser/ckreleaser.jar \
ckreleaser.release \
../.. release "3.4.1 (SVN/Smallbox)" \
ckeditor_3.4.1_svn_smallbox \
--run-before-release=$LANGTOOL -
It's time to run the releaser:
% ./_dev/releaser/release.shIf all goes well, the thing will churn for a while and spit out a bunch of information on what it's up to. Once it's finished, there will be a new directory named _ckeditor/_dev/releaser/release, which will contain archives containing your new custom CKEditor release, along with an uncompressed directory tree containing the minified release tree:
% ls -l ./_dev/releaser/release/
total 3580
-rw-r--r-- 1 torben torben 1541785 2010-08-11 10:53 ckeditor_3.4.1_svn_smallbox.tar.gz
-rw-r--r-- 1 torben torben 2116152 2010-08-11 10:53 ckeditor_3.4.1_svn_smallbox.zip
drwxr-xr-x 10 torben torben 4096 2010-08-11 10:53 release -
Move the original ckeditor/ directory away for safekeeping and unpack the new release tarball in its place. Make sure the directory name and permissions are OK, and load up a CKEditor instance. You should now have a properly minified custom skin, complete with reduced load times and reduced number of stylesheet loads.
Conclusion
While this does help in the endless battle of IE vs. everything else, there is still work to be done. Work is planned to introduce stylesheet optimization to a future version of the core of Smallbox to further help avoid this problem, and it's hoped that IE 9 will finally do away with the ridiculous 31-stylesheet limitation which has plagued IE for its entire life. Meanwhile, this is just another tool in the workshops of those of us tasked with trying to make IE play nicely with the rest of the world. And as I mentioned earlier, there are other reasons to want to do this anyway: smaller client download sizes, reduced number of HTTP requests required for complex page, and so on.
Hopefully this howto can help someone else looking to minify or publish custom CKEditor skins or plugins, for whatever reason.

Thank you for executing the launch of our new website quickly and efficiently, through a fantastic client service experience.
Heather Greene, Marketing Director
The Spa Ritual | Santé Spa


Wow… that is some work around. Thank you for the detailed post. Hopefully this saves someone else some time and frustration.
It's not as bad as it looks. Really.
Hello friend. My partner and i really love your article and your current web site all in all! The posting is actually really clearly composed and also without difficulty understandable. The Blog style is awesome as well! Would be awesome to discover where My partner and i are able acquire that. Please continue to keep up the very good work. We require even more this sort of website owners like you online and much fewer spammers. Great mate!
Thanks for taking the time to write that, I found it very educational. If you get a chance you should visit my site as well. I hope you have a great day!
I really loved reading your blog. It was very well written and simple to undertand. Unlike additional blogs I have read. I also found it very interesting. In fact after reading, I had to go show the spouse and she ejoyed it as well!