Rayrun
← Back to Discord Forum

Prevent fetching specific resources

Is it possible to fetch a page without downloading fonts?

For a specific page the fonts (ttf, otf, woff, woff2) are massive (over 20MiB !) and provide no value.

Is there a Playwright setting to prevent fetching specific resources? So I could exclude *.ttf or whatever (fonts, css, js, video, audio, etc.)

This thread is trying to answer question "Is there a Playwright setting to prevent fetching specific resources such as fonts?"

4 replies

Specific setting no, however you can use route with abort, something like: await page.route('wildcardToMatchFontsRequest', (route) => route.abort())

here is a video with more details: https://www.youtube.com/watch?v=hk6ND5gVdyc

Thanks @Oci I will look into that!

@oci1458 I assume I can use await page.route(..) multiple times for different scenarios, or must I pack everything into a single call?

You should be able to use it multiple times, saying 'should' because I always end up using regex to match as much as possible, the match param can use regex: await page.route(/yourRegex/...

Related Discord Threads

TwitterGitHubLinkedIn
AboutQuestionsDiscord ForumBrowser ExtensionTagsQA Jobs

Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email luc@ray.run.