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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T14:14:48+00:00 2026-06-17T14:14:48+00:00

SHORT: Is there a possibility to import less files on demand, only when the

  • 0

SHORT: Is there a possibility to import less files “on demand”, only when the function/variable has not been defined yet?

LONG: Let’s assume I have LESS file containing my styles for the page. Let’s call it styles.less. In addition, I have 5 more LESS files. Everyone of there contains generic design primitives, for example design of the info box which I use in many projects – that’s the reason it’s not been merged to styles.less. Let’s assume it’s called .infobox {}.
Then, is it somehow possible to “try” to import that 5 files when .infobox is not found in styles.less? I’m interested in both compiling via lessc (module for node) and “on-the-fly” compilation in web browser.

I hope my examples clarify the situation enough – if not, feel free to comment and I’ll edit the question to provide more information.

  • 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-17T14:14:49+00:00Added an answer on June 17, 2026 at 2:14 pm

    I have not been able to find a way to make this fully automated. I also do not know if you are desiring this functionality in order to reduce @import requests or to simply reduce the final CSS to not load items it does not need.

    If you do not need it to be fully automated, and you are seeking just to reduce the CSS generated, and you do not have too many classes you desire to do this with, then you can do something like the following in your styles.less file.

    //have at the top of the file some variables set to 0 or 1 if the class
    //is present or absent in that file
    @usesClass-infobox: 0;
    
    //set up a mixin to load it if NOT in the file
    .setClass-infobox(@set) when (@set = 0) {
      @import 'infobox.less'; 
    }
    
    //a default mixin to do nothing otherwise
    .setClass-infobox(@set) {}
    
    //call the mixin
    .setClass-infobox(@usesClass-infobox);
    

    Of course, this does not really help automate the process. After all, if you know .infobox is not in the styles.less file, then you would just add the @import anyway without any extra mixins to check. The only real value this gives is that it sets up a section of variables that basically informs the coder that “Hey, there are modules that can be loaded for this functionality if you are not including it here; so tell me, are you including it?”

    Again, I’m not sure if this totally resolves what you are going for. I offered it as it could be useful for some people in some situations.

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

Sidebar

Related Questions

Short version question : Is there navigator.mozIsLocallyAvailable equivalent function that works on all browsers,
Short: Is there a way we can push to multiple remotes simultaneously using Github
Is there a short way to do this? def value @val end def value=(value)
Short Version: Is there a/what is the suggested way to return error details to
short version: Is there a good time based sampling profiler for Linux? long version:
Is there a short way to check/get for least significant bit in a 32-bit
Is there any short syntax for if-else statement in objective C like PHP: if($value)
The short version: is there a way to to write an and or an
To keep it short and sweet: There is hibernate-commons-annotations 4.1.0-Final and hibernate-annotations 3.5.6-Final. I'm
Is there any keyboard short cut to compile selected file in C++ project in

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.