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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T21:39:54+00:00 2026-06-13T21:39:54+00:00

I would like to add a theme support to my single page application. The

  • 0

I would like to add a theme support to my single page application. The requirement is that the theme change must be done locally by javascript (no server calls) to be used in offline mode. I use angularjs, so html will be changed in the router.

The only problem that I have, is how to treat css. Is there any js library to help me load css files? Are there any problems involved in that?

EDIT: I have found the following library https://github.com/rgrove/lazyload/ which should do the job of loading css files. The only downside of the library is that the last update of the library is more than one year ago. A more actively developed library would be appreciated.

  • 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-13T21:39:57+00:00Added an answer on June 13, 2026 at 9:39 pm

    style elements can be added and removed in JavaScript. Simply create the element and add it to the page to apply the rules therein, and remove the element to remove its rules. You can do the same with link elements referring to external stylesheets, but if you want to be sure to work in offline mode and if the sheet may not have been cached, style elements with inline rules might work better.

    Here’s an example using a style element:

    (function() {
      var css = "body { color: green; }";
    
      document.getElementById("theButton").onclick = toggleStyle;
    
      function toggleStyle() {
        var style = document.getElementById("styleOne");
        if (style) {
          // Remove it
          style.parentNode.removeChild(style);
        }
        else {
          // Add it
          style = document.createElement('style');
          style.id = "styleOne";
          if (style.styleSheet) {
              style.styleSheet.cssText = css;
          }
          else {
              style.appendChild(document.createTextNode(css));
          }
          document.body.appendChild(style);
        }
      }
    
    })();
    

    Live Copy | Source

    Using a link would be even easier, because you don’t have to deal with browser differences around where the style text goes.

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

Sidebar

Related Questions

I would like to add some scripting support to a Silverlight 4 application that
I would like to add a small dice-rolling effect to my Javascript code. I
I'm looking to add some basic theme support to my web application, with users
I would like to add Unicode support to a C library I am maintaining.
I would like to add value to my website that I have developed at
Is there any preexisting class that helps support add/remove EventListener operations? (kind of like
I've written a grid control and would like to add support for the mouse
I have a wxWidgets application and would like to add a way for users
I'm working on a shipping tracking number library and would like to add support
I have own project and i would like add for this class same as

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.