DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

The software you build is only as secure as the code that powers it. Learn how malicious code creeps into your software supply chain.

Apache Cassandra combines the benefits of major NoSQL databases to support data management needs not covered by traditional RDBMS vendors.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Related

  • The Cypress Edge: Next-Level Testing Strategies for React Developers
  • Overcoming React Development Hurdles: A Guide for Developers
  • Why React Router 7 Is a Game-Changer for React Developers
  • Unleashing the Power of WebAssembly to Herald a New Era in Web Development

Trending

  • Unlocking AI Coding Assistants: Generate Unit Tests
  • MySQL to PostgreSQL Database Migration: A Practical Case Study
  • Integrating Model Context Protocol (MCP) With Microsoft Copilot Studio AI Agents
  • Metrics at a Glance for Production Clusters
  1. DZone
  2. Coding
  3. JavaScript
  4. How to Use Chrome Developer Tools JavaScript Source Snippets

How to Use Chrome Developer Tools JavaScript Source Snippets

With Chrome Code Snippets we can ‘run’ small chunks of code without using the console. And using a gist, we can import and export them to a file.

By 
Alan Richardson user avatar
Alan Richardson
·
Sep. 28, 16 · Tutorial
Likes (1)
Comment
Save
Tweet
Share
8.0K Views

Join the DZone community and get the full member experience.

Join For Free

We already know that we can run custom JavaScript code from the console. I explained that in this blog post.

And we can use Google Chrome Code snippets to reuse that code over time.

By default, we can’t import and export, but people have written helpful code to let us do that as well.

Google Chrome Snippets

The Google Chrome Snippets tool allows you to store short ‘snippets’ of JavaScript code in the dev tools, rather than having to copy and paste into the console all the time.

https://developers.google.com/web/tools/chrome-devtools/debug/snippets/?hl=en

If you right click on a snippet you can ‘run’ it.

Remember to hit  ctrl+s to save it, you’ll know if it is saved because it will no longer have the ‘*’ next to it.

Collections of Snippets

You can find collections of other people’s snippets online.

  • https://bgrins.github.io/devtools-snippets/
  • https://github.com/bgrins/devtools-snippets RSS
  • https://github.com/bahmutov/code-snippetsRSS

Can We Import and Export Snippets?

If you Ctrl + Shift + I and open a ‘secondary’ Dev tools for the Dev Tools, then this gives you access to the snippets API.

E.g. stackoverflow.com/questions/34936456

InspectorFrontendHost.getPreferences(function(prefs) {
    console.log(prefs.scriptSnippets);});

We can import and export snippets using this gist:

gist.github.com/soundyogi/03df95505604c8351212

Copy and paste theraw gist into your ‘secondary’ dev tools. After you import, remember to ‘save to chrome’.

Summary

If you find yourself working from the console, then this is a really useful way to manage your code snippets. And having the ability to import and export allows you to keep your snippets clean and only have the snippets for the application you are testing.

Snippet (programming) dev JavaScript Google Chrome

Published at DZone with permission of Alan Richardson, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • The Cypress Edge: Next-Level Testing Strategies for React Developers
  • Overcoming React Development Hurdles: A Guide for Developers
  • Why React Router 7 Is a Game-Changer for React Developers
  • Unleashing the Power of WebAssembly to Herald a New Era in Web Development

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!