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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:22:27+00:00 2026-06-17T12:22:27+00:00

I am using LESS ( http://lesscss.org ) and it says … JavaScript evaluation JavaScript

  • 0

I am using LESS ( http://lesscss.org ) and it says …

JavaScript evaluation

JavaScript expressions can be evaluated as values inside .less files. This is done by wrapping the expression with back-ticks:

The example provided is …

@height: `document.body.clientHeight`;

So I’ve tried to do this in my html …

<script type="text/javascript">
    var fred=5;
</script>
<link rel="stylesheet/less" type="text/css" href="styles.less">
<script type="text/javascript" src="http://lesscss.googlecode.com/files/less-1.2.1.min.js"></script>     

and this in styles.less …

@height:`fred + "px"`;

.mydiv {
    background-color:green;
    height:@height;
}

But it just won’t work!
Also tried variations on this such as using …

@height:`fred`px;
@height:`fred`;

If I use …

@height:20px;

It works as expected but I need to use Javascript evaluation.
I would really appreciate it if someone could help – Answers focusing on answering the question and not asking why I need to use Javascript evaluation would be greatly appreciated. Thanks very much all

Its worth noting that if I do …

@height:`freddd`px;

where freddd is undefined, I get an error from the less compiler – hence it seems to know that fred is defined. However, currently I am not getting an error – it is just not doing anything when I use Javascript variable values.

  • 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-17T12:22:28+00:00Added an answer on June 17, 2026 at 12:22 pm

    I am working on the same thing. The way I have been testing the expression is to compile the less file in the browser as you are doing (I am using firefox with firebug). I inspect my rendered css by inspecting the head section of the rendered page and looking for
    <style id="less:yourLessFileName-less-styles" type="text/css"> . Twirl that file open and you will see the compliled css. Scroll down until you find your selector and rule you are using the javascript expression for and see how it rendered.

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

Sidebar

Related Questions

I can limit an array to values less than or greater than using individual
I modified bootstrap.css using LESS so I can use Bootstrap only inside of a
Hi i was using HttpModule to Perform Extension-Less URL Rewriting as explained at http://weblogs.asp.net/scottgu/archive/2007/02/26/tip-trick-url-rewriting-with-asp-net.aspx
For my website, I'm considering using Less . Can I have some problem of
I write my CSS with Lesscss using it on client side (with compiler less.js).
I made a small page ( http://www.ovlu.li ) using CMS Made Simple ( http://www.cmsmadesimple.org/
I'm using Twitter Bootstrap on a project at the moment, including the LESS files
Is the only benefit of using css image sprites that there is less http
I am using the python mock framework for testing (http://www.voidspace.org.uk/python/mock/) and I want to
I'm using a src less iframe to develop a javascript widget to protect my

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.