Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8772613
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T18:04:41+00:00 2026-06-13T18:04:41+00:00

ok so what I am trying to do is manually handle my assets when

  • 0

ok so what I am trying to do is manually handle my assets when using express. What I mean is that I do not what to have to have every stylesheet/javascript file on every page. So I wanted to be able to specify in each route whether I wanted to use another javascript file or not. Ex:

app.get('/testing',function(req,res,next){
      assets.addJS('my-javascript-file');
      res.render('testing');
});

So now when the template goes to render I want all of those javascript files that have been added in a local variable. I do not want to pass them on each call to render because I will want to add javascript in other places and may not necessarily need to send anything to the template which would cause me not to pass it by accident. Another thing that I want to implement is caching. I know by default it sends back the 304 not modified once it has the asset but I dont even want it making that request so I was hoping to do a query string on the files when they are output with maybe the last time they were modified and that way if I change them it will automatically tell the users browser to get the newest files but other than that it will cache them saving me bandwidth / requests (amazon s3 charges for these). If anyone can point me in the right direction or if there is already a plugin out there for this please let me know. Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T18:04:42+00:00Added an answer on June 13, 2026 at 6:04 pm

    You could build an asset manager around this:

    app.get(function(req, res) {
      res.locals.files = [ 'somefile.js', 'somefile2.js' ];
      res.render('someview');
    });
    

    The view would just create multiple script files.

    head
      each file in files
        script(src=base_url + '/' + file)
    

    If you want to merge the files into one request you probably need to extend this even more. You could create a route that can take an array of files and merges them on each request. You can serve files with res.sendFile. This will take care of all the headers and caching if I remember correctly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Following a MSDN web page, I am trying to manually run mstest within my
Im using sql server 2012 and its replication feature. Here im trying to manually
I have a spinner and I am trying to populate it manually in the
In my Server application I'm trying to handle the Server which is using ServerSocket
I'm trying to write a program that will take an HTML file and make
I'm trying to make DuplicateHandle() for a file that another process writes. I succeeded,
I'm trying to upload a PDF file to a website using Hot Banana's content
I'm trying to figure out how to handle events using coroutines (in Lua). I
I am trying to get routed events working with child controls that will manually
I'm trying to deploy a JSP-page on Jetty, using the Jetty WTP plugin for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.