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

  • Home
  • SEARCH
  • 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 9266497
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T14:19:57+00:00 2026-06-18T14:19:57+00:00

I am trying to build a progressively enhanced page that works for JS and

  • 0

I am trying to build a progressively enhanced page that works for JS and non-JS users. I would like to hide some form controls initially for JS users, but always show them for non-JS users.

My question is about how to do this without creating a distracting “visible, then instantly hidden” flash of content for JS users.

For example, in the JS version, I want to collapse part of my search form, and instead show a ‘click here for extra options’ button. I do this as follows:

$(document).ready(function() { 
  $("#extra-options").hide();
  ...
  $("#show-extra-options").click(function() { 
     $("#extra-options").slideToggle();
  });
});

This works, but it means that for JS users, when the page loads, the extra options are visible for 500ms or so, then they vanish. It’s rather distracting.

Is there any sensible way to get around this?

StackOverflow has just suggested this answer: is this sensible? Sorry if this is now a duplicate question, but I figure it’s still worth writing this question in my own language, as I didn’t find the answer during searching.

  • 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-18T14:19:59+00:00Added an answer on June 18, 2026 at 2:19 pm

    Add this in your script tag in the head:

    $('html').addClass('js');
    

    Then you can use that to show and hide elements:

    .hasJs { display: none; }
    .js .hasJs { display: block; }
    .js .noJs { display: none; }
    

    You can hide content for either users with or without Javascript:

    <div class="hasJs">Some content only visible for JS users.</div>
    <div class="noJs">Some content only visible for non-JS users.</div>
    

    As the class and CSS are in the head, the elements will already be styled when they come into existance when the body is parsed.

    Demo: http://jsfiddle.net/Guffa/YuAyr/

    This is a similar approach to the one in the first answer to the question that you linked to, but this is somewhat cleaner because you don’t have to add a class to the html element in the markup, and the code simply adds the class instead of removing it.

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

Sidebar

Related Questions

Im trying to build a simple AJAX script that uses a form to send
Im trying to build a form that calculates a total price based on a
Im trying to build a addin that can take some a selection of cells
Im trying to build a function so that when users are scrolling over input
Im trying to build a page that will allow a user to select a
I am trying build a web page that will construct elements from JSON file
Trying to build a plugin effect that will some what look better than this
I'm trying build an App Engine connected Android application and am having some problems
I have a std::vector< tr1::shared_ptr<mapObject> > that I'm trying build from data contained in
Trying to build a project that uses managed C++/CLI and it compiles successfully when

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.