Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
jquery-detect-environment
Advanced tools
A lightweight jQuery plugin that dynamically adds CSS classes to the html tag
A lightweight jQuery plugin that dynamically adds CSS classes to the <html>
tag based on the device type, operating system, screen size, orientation, browser, internet connection, time of day, color scheme preference, and pixel density. This helps create responsive and adaptive designs easily.
The plugin automatically detects and adds classes for:
device-mobile
or device-desktop
os-windows
, os-macos
, os-linux
, os-android
, os-ios
width-xs
, width-sm
, width-md
, width-lg
, width-xl
orientation-portrait
or orientation-landscape
browser-chrome
, browser-firefox
, browser-safari
, browser-edge
status-online
or status-offline
time-morning
, time-afternoon
, time-evening
, time-night
prefers-dark-mode
or prefers-light-mode
pixel-ratio-1x
, pixel-ratio-2x
, or pixel-ratio-3x
Include jQuery in your project (if not already included):
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
Include the plugin script (choose between the full or minified version):
<script src="path/to/jquery.detect-environment.js"></script>
<script src="path/to/jquery.detect-environment.min.js"></script>
The plugin initializes automatically when the document is ready and dynamically adds classes to the <html>
tag. It also listens for window resize, orientation change, and network connection events to update classes in real-time.
$(document).ready(function() {
$('html').detectEnvironment();
});
The classes added to <html>
will update automatically, so you can use them directly in your CSS for responsive and adaptive design.
With this plugin, the <html>
tag might look like:
<html class="device-desktop os-windows width-lg orientation-landscape browser-chrome status-online time-afternoon prefers-light-mode pixel-ratio-2x">...</html>
Here are some sample classes and what they represent:
The plugin listens for the following events to update classes dynamically:
This project is licensed under the MIT License.
This portion of the README.md
file provides examples and explanations of the classes generated by the plugin, describes the events it listens for, and includes a brief note on the license. It’s designed to help users understand how to work with the classes generated by the plugin for responsive design.
FAQs
A lightweight jQuery plugin that dynamically adds CSS classes to the html tag
We found that jquery-detect-environment demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.