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 7501107
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T20:25:51+00:00 2026-05-29T20:25:51+00:00

I have a reusable google-maps widget that can be plugged into any page that

  • 0

I have a reusable google-maps widget that can be plugged into any page that might want to use it.

Widget has :

  • Google maps specific js includes.
  • Map specific css to style the map.

Problem:

  • Widget code gets included as server-side include.
  • Widget specific js and css has to included with the widget code.
  • Therefore, if widget repeats 5 times on a page, then the include statements for js and css get included 5 times.
  • I can-not keep the widget specific includes in the <head> tag, since if the widget is not used on the page, then un-used js and css gets downloaded on client.

So, how should I keep the js and css so they gets included only when the widget is used and no multiple include are done in case the widget is repeated.

My technology:

  • Django-Python [ If that matters ]
  • I also faced the same problem on php

Note :

  • I understand that including the same js and css multiple times on a page doesn’t forces the client to download them multiple times, but I want to avoid the multiple includes.

How should I tackle this problem ?

Please feel free to ask for more info, if I missed something. 🙂

  • 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-05-29T20:25:53+00:00Added an answer on May 29, 2026 at 8:25 pm

    Depending on your use case a few options:

    1. Use a separate base template for all pages that need the widget; in that base add the required js/css files. For all views that need the widget, inherit from the modified base.

    2. Using javascript implement conditional includes.

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

Sidebar

Related Questions

I'd like to have a reusable validator that I can use on a group
I have some reusable HTML snippets that I want to 'include' in a number
I have a reusable HTML fragment that I use to list items. So to
I have this class that tries multiple methods of getting data from Google maps
let us assume that I have a reusable business layer that further makes use
I have a need for unique reusable ids. The user can choose his own
I have a fair number of Python scripts that contain reusable code that are
Q1 If I have a reusable library that is available, that uses interfaces with
I'd like to have a reusable logging method or function that spits out the
I am writing an application using Symfony. I have some reusable components that I

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.