Search code examples
javascriptlarge-data

Good or bad idea : load database as a separate .js file


I have a web page where you can customize your game character. In order to speed up browsing (gems) I load entire gems database (600 entries, 247KB) as a separate .js file, so it can be cached and I don't need to load it every time.

I don't notice a delay, is it still a bad idea?
Should I ajax-get necessary records on the fly instead?

FYI: I use ASP.NET MVC 2.0, here is loading the script:

<script type="text/javascript" src='./Data.aspx/Gems'></script>

And here is the action:

[OutputCache(Duration = 14400, VaryByParam = null)]
public ActionResult Gems() {...}

EDIT: My main concern is not load time, but memory usage. Is it going to have noticeable impact having excra 250KB of javascript loaded/parsed by browser?


Solution

  • I find it a pretty good idea. Plus, if you ever need to "upgrade" the GEMS database you can just load up the scripts with a version tag like

     <script type="text/javascript" src='./Data.aspx/Gems?v=1232'></script>
    

    Where v=123 will force the user to download the new version if required.