Skip to main content
BETAUnder active development. Some features may not work as expected.

What Is a Headless Browser? Scraping JavaScript-Heavy Sites

intermediate

A headless browser is a web browser that runs without a graphical user interface. It can load pages, execute JavaScript, and render the DOM just like a regular browser — but operates entirely in the background, controlled by code.

Why Headless Browsers Matter for Scraping

Many modern websites use JavaScript to load content after the initial page load. If you fetch these pages with a simple HTTP request, you get an empty shell. A headless browser executes the JavaScript and gives you the fully rendered page.

python
# This returns empty/incomplete HTML for JS-heavy sites
import requests
response = requests.get("https://spa-website.com")
# response.text has no product data — it's loaded by JavaScript

# Headless browser gets the full rendered page from playwright.sync_api import sync_playwright with sync_playwright() as p: browser = p.chromium.launch(headless=True) page = browser.new_page() page.goto("https://spa-website.com") page.wait_for_selector(".product") # wait for JS to load html = page.content() # now contains all the data browser.close()

Popular Headless Browser Tools

ToolLanguageSpeedAnti-Bot Resistance
PlaywrightPython, JS, C#FastGood
PuppeteerJavaScriptFastGood
SeleniumMulti-languageSlowerModerate

Headed vs. Headless Mode

  • Headless (headless=True): No visible window. Faster, uses less memory. Use for production scraping.
  • Headed (headless=False): Shows the browser window. Use for debugging and development.

Performance Considerations

Headless browsers are 10-50x slower than simple HTTP requests because they:

  • Download all assets (CSS, JS, images)
  • Execute JavaScript
  • Render the page layout
  • Use significantly more memory
Pro tip: Before using a headless browser, check if the site loads data via API calls. You can intercept these calls in DevTools' Network tab and hit the API directly — much faster than rendering the full page.

Learn Headless Browser hands-on

This glossary entry covers the basics. The Master Web Scraping course teaches you to use headless browser in real projects across 16 in-depth chapters.

Get Instant Access — $19

$ need_help?

We're here for you