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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T20:41:54+00:00 2026-06-18T20:41:54+00:00

I would like to load different scripts if the user is on a smartphones/tablets

  • 0

I would like to load different scripts if the user is on a smartphones/tablets or on a laptop.

Here is the result that I want :

Laptop:

<script src="http://code.jquery.com/jquery-1.8.2.min.js"></script> 

smartphones and tablets

<link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" />
<script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>

How can I do it?

  • 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-18T20:41:55+00:00Added an answer on June 18, 2026 at 8:41 pm

    You’re looking at either sniffing the User-Agent to detect for specific devices or you can use the browser/screen width to determine which category your user falls under.

    To add scripts based on browser width you can do something like this:

    <script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
    <script>
        (function ($) {
    
            //check if the browser width is less than or equal to the large dimension of an iPad
            if ($(window).width() <= 1024) {
    
                //create an AJAX request for the CSS file
                $.ajax({
                    url     : 'jquery.mobile-1.2.0.min.css',
                    success : function (response) {
                        $('head').append('<style>' + response + '</style>');
                    }
                });
    
                //create an AJAX request for the JS file, setting the dataType to 'script' will have jQuery automatically evaluate the JS code in the global scope
                $.ajax({
                    url      : 'jquery.mobile-1.2.0.min.js',
                    dataType : 'script'
                });
            }
        })(jQuery);
    </script>
    

    This has a few caveats though.

    1. Small desktop browsers can be <=1024px wide so you’ll have some overlap between tablet and desktop users.
    2. The JS/CSS needs to be hosted on your web server so you can access them without Cross-Domain-Policy issues.

    The CSS/JS inclusion will most likely work for you no matter how you detect mobile/tablet devices. There are scripts out there to detect devices that run server-side as well as client-side, a quick Google search will bring up many of these scripts. I have not used these scripts however so I can’t offer much guidance on their usage.

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

Sidebar

Related Questions

$('#selector').click(function() { // here I would like to load a javascript file // let's
I have several PDF templates that I would like to load and modify and
I would like to load different web2py components in the same view, but not
I would like to load some data stored in a file into my mysql
I would like to load a new extension in a symfony2 project for twig
I would like to load a HTML document and modify it's text in PHP.
i would like to load xml into dataset with only 2 columns (name, price)
I have an assembly I would like to load from a sub-folder of the
I have requirement where some times I would like to load children as well
I have a C# .Net 2.0CF application where I would like to load a

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.