# Best practices for managing CSS, JavaScript, images?

**URL:** <https://www.ruby-forum.com/t/best-practices-for-managing-css-javascript-images/129681>\
**Category:** Radiant CMS\
**Created:** [February 20, 2008, 6:04pm UTC](https://www.ruby-forum.com/t/best-practices-for-managing-css-javascript-images/129681 "2008-02-20T18:04:09Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Timothy\_Jones](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/a3d4f5/32.png) [@Timothy\_Jones](https://www.ruby-forum.com/u/Timothy_Jones)\
**Post date:** [February 20, 2008, 6:04pm UTC](https://www.ruby-forum.com/t/best-practices-for-managing-css-javascript-images/129681/1 "2008-02-20T18:04:09Z")

</div>

Greetings,

I’m just ramping up on Radiant. Apologies if I’ve missed this in a  
FAQ somewhere, but I’m looking for some recommendations on managing  
these types of assets on a Radiant-based site. I found a mailing list  
thread from 2006, but it didn’t seem to have a conclusion.

With non-Radiant sites I have Apache serve up these static files,  
bypassing Rails entirely. What are the recommended best practices  
with Radiant? I’d like to manage them through the web interface, so  
that other folks don’t have to deal with Subversion, deployment, etc.

Do folks generally just embed the CSS and JavaScript in a layout and  
serve it dynamically? And caching?

What about images (icons, backgrounds, etc.)? I’d like a way to  
upload and delete them from a browser, again to avoid Subversion and  
deployment hassles. It looks like the Gallery extension might work  
for this. Any other recommendations?

Thanks!

Tim Jones  
Barbary Codes and Data

---

<div class="post-metadata">

**Author:** ![Timothy\_Jones](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/a3d4f5/32.png) [@Timothy\_Jones](https://www.ruby-forum.com/u/Timothy_Jones)\
**Post date:** [February 20, 2008, 6:12pm UTC](https://www.ruby-forum.com/t/best-practices-for-managing-css-javascript-images/129681/2 "2008-02-20T18:12:25Z")

</div>

Tim,

Chris P., with whom I’ve spoken privately, is working on an  
extension that will allow you to manage CSS and JavaScript separate from  
the page sitemap and have them be cached in some reasonable place so  
they can be served by your web server. In the meantime, you can create  
pages in the sitemap that have special layouts that specify their  
content type. It means an extra hit to Radiant to get the CSS or JS, but  
it’s a good interim solution.

To accomplish this, I would create a child of the homepage called  
“Stylesheets”, and create a layout for it like this:

Name: CSS  
Content type: text/css  
Content: \<r:content /\>

Then create child pages of “Stylesheets” that are your individual  
stylesheets, modifying the slug to end in “.css” if you desire.

You can do the same for JS.

Cheers,

Sean

---

<div class="post-metadata">

**Author:** ![Timothy\_Jones](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/a3d4f5/32.png) [@Timothy\_Jones](https://www.ruby-forum.com/u/Timothy_Jones)\
**Post date:** [February 20, 2008, 6:17pm UTC](https://www.ruby-forum.com/t/best-practices-for-managing-css-javascript-images/129681/3 "2008-02-20T18:17:44Z")

</div>

Sean, you’re too fast…

Well Timothy, you’re in luck. At John’s request, I have put together an  
extension to manage CSS & JS files as assets separate from normal  
pages. I’ve got a little rearranging that he’s asked for before I  
release it into the wild. Look for an announcement here soon - probably  
by this weekend.

In the meantime, Sean’s explanation saved me some time explaining it  
here and works well enough for how (though we’ve all felt it a little  
hack-ish – hence the new solution).

As to other assets, Sean has a very well used PageAttachments extension,  
Andrea F. has a Gallery extension and Keith B. also has an  
Assets extension (though he’ll be the first to tell you it’s not  
production ready right now). Links and info on these third party  
extensions can be found here:  
[http://wiki.radiantcms.org/Thirdparty\_Extensions](http://wiki.radiantcms.org/Thirdparty_Extensions)

-Chris

---

<div class="post-metadata">

**Author:** ![Timothy\_Jones](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/a3d4f5/32.png) [@Timothy\_Jones](https://www.ruby-forum.com/u/Timothy_Jones)\
**Post date:** [February 20, 2008, 10:31pm UTC](https://www.ruby-forum.com/t/best-practices-for-managing-css-javascript-images/129681/4 "2008-02-20T22:31:55Z")

</div>

I’ve just got onto using radiant last week, it’s been great to get up  
to speed fast and be able to slam out some sites that have been  
languishing.

While I’ve been able to install some extensions like shard fine others  
won’t load when I issue:  
rake db:dbmigrate:extensions

I receive the following error:

Could not load extension from file: meta\_data\_extension.  
#\<NameError: uninitialized constant MetaDataExtension\>

Which I’m unsure of how to resolve.

thanks in advance

Brian Loomis  
Brian Loomis  
removed\_email\_address@domain.invalid  
(208) 562-3944

---

<div class="post-metadata">

**Author:** ![Timothy\_Jones](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/a3d4f5/32.png) [@Timothy\_Jones](https://www.ruby-forum.com/u/Timothy_Jones)\
**Post date:** [February 20, 2008, 10:49pm UTC](https://www.ruby-forum.com/t/best-practices-for-managing-css-javascript-images/129681/5 "2008-02-20T22:49:09Z")

</div>

Make sure that the directory containing the extension is named the same  
as the \*\_extension.rb file inside it. If it’s metadata\_extension.rb,  
name the directory metadata, etc.

Sean

---

<div class="post-metadata">

**Author:** ![Timothy\_Jones](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/a3d4f5/32.png) [@Timothy\_Jones](https://www.ruby-forum.com/u/Timothy_Jones)\
**Post date:** [February 21, 2008, 12:07am UTC](https://www.ruby-forum.com/t/best-practices-for-managing-css-javascript-images/129681/6 "2008-02-21T00:07:47Z")

</div>

I did change the extension folder name to match the .rb file then ran  
the command again with this error:

Could not load extension from file: page\_meta\_extension\_extension.  
#\<NameError: uninitialized constant PageMetaExtensionExtension\>

Am I to load extensions in to the extensions folder at the root of  
site or the entensions folder in vendors where the three that radiant  
comes with are located/

shards loaded and worked from the root extension folder but page\_meta  
data will not.

On Feb 20, 2008, at 2:48 PM, Sean C. wrote:

> > languishing.
> > 
> > Radiant mailing list  
> > Site: [http://lists.radiantcms.org/mailman/listinfo/radiant](http://lists.radiantcms.org/mailman/listinfo/radiant)  
> > Brian Loomis  
> > removed\_email\_address@domain.invalid  
> > (208) 562-3944

---

<div class="post-metadata">

**Author:** ![Timothy\_Jones](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/a3d4f5/32.png) [@Timothy\_Jones](https://www.ruby-forum.com/u/Timothy_Jones)\
**Post date:** [February 21, 2008, 9:50am UTC](https://www.ruby-forum.com/t/best-practices-for-managing-css-javascript-images/129681/7 "2008-02-21T09:50:10Z")

</div>

Sounds good, Chris - also looking forward to this one, just what I  
need 🙂

---

<div class="post-metadata">

**Author:** ![Timothy\_Jones](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/a3d4f5/32.png) [@Timothy\_Jones](https://www.ruby-forum.com/u/Timothy_Jones)\
**Post date:** [February 21, 2008, 12:33am UTC](https://www.ruby-forum.com/t/best-practices-for-managing-css-javascript-images/129681/8 "2008-02-21T00:33:10Z")

</div>

You are having the same problem still. Don’t use \_extension on the  
directory name.

Sean
