






































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!







































































Question 1. What is the primary purpose of webhint? A) To minify JavaScript files B) To lint web projects for bestâpractice issues C) To compile TypeScript to JavaScript D) To generate service workers automatically Answer: B Explanation: webhint works as a linting tool that analyses HTML, CSS, JS and other web assets to detect bestâpractice violations, not as a build or compilation tool. Question 2. Which npm command installs webhint globally? A) npm install webhint --save-dev B) npm install - g @hint/cli C) npm install webhint --global D) npm add webhint - g Answer: B Explanation: The official CLI package is @hint/cli; the -g flag installs it globally. Question 3. How can you run webhint against a remote URL? A) hint https://example.com B) webhint scan https://example.com C) hint https://example.com --format json D) npx hint https://example.com Answer: D Explanation: Using npx hint <url> executes the CLI without a prior global install, scanning the remote site. Question 4. In a .hintrc file, what does the âextendsâ property do?
A) Adds custom parsers to the run B) Merges settings from another configuration C) Overrides the default formatter D) Enables the Chrome connector automatically Answer: B Explanation: âextendsâ allows you to inherit rules from an existing hint configuration such as progressive-web-apps. Question 5. Which connector enables webhint to run audits in a real Chrome browser? A) jsdom B) chrome C) edge D) puppeteer Answer: B Explanation: The chrome connector launches a headless Chrome instance to evaluate pages as a real browser would. Question 6. What file type does the âwebpack-configâ parser analyze? A) webpack.config.js or .ts files B) package.json only C) .babelrc files D) .eslintrc files Answer: A Explanation: The webpack-config parser reads the configuration file used by Webpack, which can be JavaScript or TypeScript. Question 7. Which formatter would you choose to generate an Excel report of hint results?
B)
C) Transfer-Encoding: gzip D) Accept-Encoding: gzip Answer: B Explanation: Content-Encoding: gzip tells browsers that the response body is compressed with gzip. Question 14. Which file extension indicates a minified JavaScript file by convention? A) .min.js B) .js.min C) .js.gz D) .compressed.js Answer: A Explanation: The .min.js suffix is widely used to denote a minified script. Question 15. Which HTML attribute is used for responsive images with multiple resolutions? A) srcset B) picture C) src D) sizes Answer: A Explanation: srcset provides a list of image candidates for different device pixel ratios or viewport widths. Question 16. What image format provides superior compression compared to JPEG and PNG and is supported by most modern browsers? A) BMP
B) Including a script with src="//example.com/script.js" on HTTPS C) Embedding an iframe with src="https://example.com" on HTTPS D) Fetching a stylesheet via HTTP on HTTPS Answer: C Explanation: An HTTPS iframe on an HTTPS page is safe; the other options load insecure resources. Question 20. Which header restricts browsers from interpreting files as a different MIME type? A) X-Frame-Options B) X-Content-Type-Options: nosniff C) Content-Security-Policy D) Referrer-Policy Answer: B Explanation: X-Content-Type-Options: nosniff prevents MIMEâtype sniffing. Question 21. What does the ContentâSecurityâPolicy directive âscript-src âselfââ allow? A) Inline scripts only B) Scripts from the same origin only C) All external scripts D) No scripts at all Answer: B Explanation: 'self' restricts script loading to the same origin as the page. Question 22. Which tool does webhint use to detect known vulnerabilities in npm packages? A) Snyk API
B) npm audit parser C) retire.js parser D) OWASP DependencyâCheck Answer: C Explanation: webhint includes a parser for retire.js data to flag vulnerable libraries. Question 23. Which attribute should be added to external links that open in a new tab for security? A) rel="noopener" B) target="_self" C) rel="noreferrer noopener" D) Both A and C Answer: D Explanation: Both noopener and noreferrer mitigate reverseâtabnabbing when using target="_blank". Question 24. Which key in a web app manifest defines the appâs display mode? A) start_url B) scope C) display D) orientation Answer: C Explanation: The display property controls whether the app runs fullscreen, standalone, minimalâui, or browser. Question 25. Which Service Worker lifecycle event is fired when a new worker takes control of pages?
A) ESLint B) Hint for VS Code (webhint) C) Prettier D) Live Server Answer: B Explanation: The official webhint VS Code extension surfaces hint results as you edit files. Question 29. Which command adds webhint to a GitHub Actions workflow? A) npm run hint --ci B) npx hint --format json | tee results.json C) - name: Run webhint run: npx hint. --format json --output results.json D) npm exec hint --ci Answer: C Explanation: In a GitHub Actions YAML step, you invoke npx hint . with appropriate flags to generate a report. Question 30. When creating a custom hint, which method defines when the hint is triggered? A) registerHint() B) onParseStart() C) getHintContext() D) setTrigger() Answer: B Explanation: The onParseStart (or other lifecycle hooks) specify at which stage of analysis the hint runs.
Question 31. Which connector should you use to run hints on a page that requires full browser APIs like WebGL? A) jsdom B) chrome C) edge D) puppeteer Answer: D Explanation: Puppeteer launches a real Chromium instance, providing full browser APIs such as WebGL. Question 32. Which parser is responsible for analyzing TypeScript source files? A) htmlparser B) typescript-parser C) tsparser D) @hint/parser-typescript Answer: D Explanation: The @hint/parser-typescript package parses .ts files for hinting. Question 33. Which hint would warn you if a page lacks a <link rel="manifest"> element? A) manifest-exists B) webapp-manifest C) progressive-web-apps/manifest D) pwa-manifest-missing Answer: C Explanation: The progressive-web-apps/manifest hint checks for the presence of a linked manifest file.
A) html-deprecated-elements B) a11y/obsolete-html C) progressive-web-apps/deprecated D) best-practices/obsolete-tags Answer: A Explanation: The html-deprecated-elements hint flags usage of tags no longer part of HTML5. Question 38. How does webhint determine whether a CSS file is minified? A) Checks file size against original source B) Looks for whitespace and comments count C) Uses a regex to detect line breaks and spaces D) It does not check minification automatically Answer: C Explanation: The minification hint parses the CSS and flags excessive whitespace or comments using pattern matching. Question 39. Which hint validates that all JavaScript files are using strict mode? A) javascript/strict-mode B) a11y/strict-js C) best-practices/strict-mode D) security/strict-mode Answer: A Explanation: javascript/strict-mode ensures "use strict" is present at the top of each script. Question 40. Which connector would you choose to test a site that must be rendered with Edgeâs legacy engine? A) edge
B) chrome C) puppeteer D) jsdom Answer: A Explanation: The edge connector launches Microsoft Edge, allowing testing against its rendering engine. Question 41. Which hint verifies that a page does not contain duplicate meta description tags? A) meta-duplicate B) seo/meta-description-duplicate C) best-practices/meta-duplicate D) a11y/meta-duplicate Answer: B Explanation: The SEOâfocused hint seo/meta-description-duplicate checks for multiple description meta tags. Question 42. Which hint checks that the lang attribute on the <html> element matches the pageâs language? A) a11y/html-lang B) html/lang-attribute C) best-practices/lang-match D) accessibility/lang Answer: A Explanation: a11y/html-lang ensures the lang attribute is present and correctly set.
Question 46. Which hint will alert you if a CSS file uses the !important declaration? A) css/important-usage B) best-practices/css-important C) performance/css-important D) security/css-important Answer: B Explanation: The best-practices/css-important hint discourages overuse of !important. Question 47. Which hint validates that the manifest.json file includes a short_name property? A) progressive-web-apps/manifest-short-name B) webapp/manifest-short-name C) pwa/short-name-required D) manifest/short-name Answer: A Explanation: The PWA hint progressive-web-apps/manifest-short-name checks for this property. Question 48. What does the âpreloadâ hint check for? A) That all fonts are preloaded B) That resources marked with rel="preload" have a valid as attribute C) That preloading is used only for CSS files D) That preload links are placed at the end of the body Answer: B Explanation: The hint ensures rel="preload" links include a correct as value (e.g., script, style).
Question 49. Which hint would warn about the use of eval() in JavaScript? A) security/no-eval B) javascript/avoid-eval C) best-practices/no-eval D) all of the above Answer: D Explanation: Multiple hint packages provide similar checks; any of them will flag eval() usage. Question 50. Which hint checks that the X-Frame-Options header is set to DENY or SAMEORIGIN? A) security/x-frame-options B) best-practices/x-frame-options C) http-headers/frame-options D) a11y/frame-options Answer: A Explanation: The security/x-frame-options hint validates the presence and value of this header. Question 51. Which hint validates that the HTML document has a <title> element? A) a11y/html-title B) best-practices/html-title C) seo/missing-title D) html/require-title Answer: C Explanation: The SEO hint seo/missing-title ensures every page provides a title tag.
Question 55. Which hint would warn if a page uses the deprecated document.write() method? A) javascript/deprecated-document-write B) best-practices/no-document-write C) security/no-document-write D) all of the above Answer: D Explanation: All listed hints flag the use of document.write as a bad practice. Question 56. Which hint checks that the lang attribute value follows ISO 639â1 codes? A) a11y/lang-iso B) html/lang-iso C) best-practices/lang-iso D) accessibility/lang-iso Answer: A Explanation: a11y/lang-iso validates that the language code is a twoâletter ISO standard. Question 57. Which hint ensures that the viewport meta tag does not contain user- scalable=no? A) mobile/no-user-scalable B) best-practices/viewport-user-scalable C) a11y/viewport-user-scalable D) all of the above Answer: D Explanation: Multiple hints discourage disabling user scaling for accessibility reasons.
Question 58. Which hint verifies that the Content-Type header for CSS files is text/css? A) security/content-type-css B) http-headers/css-content-type C) best-practices/css-content-type D) all of the above Answer: D Explanation: Proper MIME type for CSS is required; any of these hints will check it. Question 59. Which hint will flag an image with a width attribute larger than its actual file size? A) performance/oversized-image B) a11y/large-image-dimensions C) best-practices/image-dimension-mismatch D) performance/image-dimension Answer: A Explanation: The performance/oversized-image hint detects images that waste bandwidth. Question 60. Which hint checks that the rel="preconnect" link includes a crossorigin attribute when needed? A) performance/preconnect-crossorigin B) best-practices/preconnect-crossorigin C) http-headers/preconnect-crossorigin D) all of the above Answer: A Explanation: For crossâorigin resources, crossorigin should be specified; the performance hint validates this.